<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
	String basePath = "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="/">
    <!-- 下拉框 -->
    <link rel="stylesheet" href="static/ace/css/chosen.css"/>
    <link href="plugins/kindeditor/themes/simple/simple.css" type="text/css" rel="stylesheet">
    <link href="plugins/kindeditor/themes/default/default.css" type="text/css" rel="stylesheet">
    <link rel="stylesheet" href="static/ace/css/datepicker.css"/>
    <!-- jsp文件头和头部 -->
    <%@ include file="../index/top.jsp" %>
</head>
<body class="no-skin">
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <form action="user/saveFarmPerson.do" name="userForm" id="userForm" method="post">
                            <input type="hidden" name="USER_ID" id="user_id" value="${pd.USER_ID }"/>
                            <input type="hidden" name="base_name" id="base_name" value=""/>
                            <div id="zhongxin" style="padding-top: 13px;">
                                <table id="table_report" class="table table-striped table-bordered table-hover">

                                    <tr>
                                        <td style="width:79px;text-align: right;padding-top: 13px;">姓名:</td>
                                        <td><input type="text" name="NAME" id="name" value="${pd.NAME }" maxlength="32"
                                                   placeholder="这里输入姓名" title="姓名" style="width:98%;"
                                                   readonly="readonly"/></td>
                                    </tr>
                                    <tr>
                                        <td style="width:79px;text-align: right;padding-top: 13px;">手机号:</td>
                                        <td><input type="number" name="PHONE" id="PHONE" value="${pd.PHONE }"
                                                   maxlength="32" placeholder="这里输入手机号" title="手机号" style="width:98%;"
                                                   readonly="readonly"/></td>
                                    </tr>
                                    <tr>
                                        <td style="width: 85px; text-align: right; padding-top: 10px;">基地:</td>
                                        <td><select name="base_id" id="base_id" data-placeholder="选择基地"
                                                    style="vertical-align: top;width: 98%;">
                                            <option value="0">请选择</option>
                                            <c:forEach var="co" varStatus="i" items="${baseList}">
                                                <option value="${co.id }">${co.name}</option>
                                            </c:forEach>
                                        </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td
                                                style="width: 85px; text-align: right; padding-top: 15px;">上传头像:
                                        </td>
                                        <td><a href="javascript:void(0)"
                                               class="onePicUpload">上传头像</a> <c:if test="${not empty pd.head_image}">
                                            <a href='${pd.head_image }' target='_blank'><img src='${pd.head_image }'
                                                                                             width='80'
                                                                                             height='50'/></a>
                                        </c:if> <input type="hidden" name=thumb id="thumb"
                                                       value="${pd.head_image }"/></td>
                                    </tr>
                                    <tr>
                                        <td
                                                style="width: 79px; text-align: right; padding-top: 13px;">人员介绍 (选填):
                                        </td>
                                        <td><textarea rows="5" cols="10"
                                                      id="desc_info" name="desc_info" maxlength="250"
                                                      style="width: 98%;" title="人员介绍">${pd.desc_info }</textarea></td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: center;" colspan="10">
                                            <a class="btn btn-mini btn-primary" onclick="save();">保存</a>
                                            <a class="btn btn-mini btn-danger" onclick="top.Dialog.close();">取消</a>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <div id="zhongxin2" class="center" style="display:none"><br/><br/><br/><br/><img
                                    src="static/images/jiazai.gif"/><br/><h4 class="lighter block green"></h4></div>
                        </form>
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>
    </div>
    <!-- /.main-content -->
</div>
<!-- /.main-container -->
<!-- basic scripts -->
<!-- 页面底部js¨ -->
<%@ include file="../index/foot.jsp" %>
<!-- ace scripts -->
<script src="static/ace/js/ace/ace.js"></script>
<!-- inline scripts related to this page -->
<!-- 下拉框 -->
<script src="static/ace/js/chosen.jquery.js"></script>
<!--提示框-->
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
<script type="text/javascript" src="static/js/common/file_upload.js"></script>
<script type="text/javascript" src="plugins/kindeditor/kindeditor-all.js"></script>
</body>
<script type="text/javascript">
    $(top.hangge());
    $(document).ready(function () {
        if ($("#user_id").val() != "") {
            $("#loginname").attr("readonly", "readonly");
            $("#loginname").css("color", "gray");
        }
    });
    //保存


    $(function () {
        debugger
        var uid = $("#user_id").val()
        //创建富文本编辑器
        TAOTAO.kingEditorParams = {
            //指定上传文件参数名称
            filePostName: "uploadFile",
            //指定上传文件请求的url。
            uploadJson: '<%=basePath%>pic/farmPerson',
            //上传类型，分别为image、flash、media、file
            dir: "image",
            extraFileUploadParams: {isCom: "01", width: 800, height: 800, quality: 0.8, end: "view", uid: uid}
        }

        TAOTAO.kingEditorAutoParams = {
            //指定上传文件参数名称
            filePostName: "uploadFile",
            //指定上传文件请求的url。
            uploadJson: '<%=basePath%>pic/farmPerson',
            //上传类型，分别为image、flash、media、file
            dir: "image",
            extraFileUploadParams: {isCom: "01", width: 200, height: 200, quality: 1, end: "thumb", uid: uid}
        }
        //初始化类目选择和图片上传器
        TAOTAO.initOnePicUpload($("input[name=thumb]").val());

    });


    function save() {
        if ($("#base_id").val() == "0") {
            $("#base_id").tips({
                side: 3,
                msg: '选择基地',
                bg: '#AE81FF',
                time: 2
            });
            $("#base_id").focus();
            return false;
        }
        $("#base_name").val($("#base_id option:checked").text());

        $("#userForm").submit();
        $("#zhongxin").hide();
        $("#zhongxin2").show();

    }

    function ismail(mail) {
        return (new RegExp(/^(?:[a-zA-Z0-9]+[_\-\+\.]?)*[a-zA-Z0-9]+@(?:([a-zA-Z0-9]+[_\-]?)*[a-zA-Z0-9]+\.)+([a-zA-Z]{2,})+$/).test(mail));
    }

    //判断用户名是否存在
    function hasU() {
        var USERNAME = $.trim($("#loginname").val());
        $.ajax({
            type: "POST",
            url: '<%=basePath%>user/hasU.do',
            data: {USERNAME: USERNAME, tm: new Date().getTime()},
            dataType: 'json',
            cache: false,
            success: function (data) {
                if ("success" == data.result) {
                    $("#userForm").submit();
                    $("#zhongxin").hide();
                    $("#zhongxin2").show();
                } else {
                    $("#loginname").css("background-color", "#D16E6C");
                    setTimeout("$('#loginname').val('此用户名已存在!')", 500);
                }
            }
        });
    }

    //判断邮箱是否存在
    function hasE(USERNAME) {
        var EMAIL = $.trim($("#EMAIL").val());
        $.ajax({
            type: "POST",
            url: '<%=basePath%>user/hasE.do',
            data: {EMAIL: EMAIL, USERNAME: USERNAME, tm: new Date().getTime()},
            dataType: 'json',
            cache: false,
            success: function (data) {
                if ("success" != data.result) {
                    $("#EMAIL").tips({
                        side: 3,
                        msg: '邮箱 ' + EMAIL + ' 已存在',
                        bg: '#AE81FF',
                        time: 3
                    });
                    $("#EMAIL").val('');
                }
            }
        });
    }

    //判断编码是否存在
    function hasN(USERNAME) {
        var NUMBER = $.trim($("#NUMBER").val());
        $.ajax({
            type: "POST",
            url: '<%=basePath%>user/hasN.do',
            data: {NUMBER: NUMBER, USERNAME: USERNAME, tm: new Date().getTime()},
            dataType: 'json',
            cache: false,
            success: function (data) {
                if ("success" != data.result) {
                    $("#NUMBER").tips({
                        side: 3,
                        msg: '编号 ' + NUMBER + ' 已存在',
                        bg: '#AE81FF',
                        time: 3
                    });
                    $("#NUMBER").val('');
                }
            }
        });
    }

    $(function () {
        //下拉框
        if (!ace.vars['touch']) {
            $('.chosen-select').chosen({allow_single_deselect: true});
            $(window)
                .off('resize.chosen')
                .on('resize.chosen', function () {
                    $('.chosen-select').each(function () {
                        var $this = $(this);
                        $this.next().css({'width': $this.parent().width()});
                    });
                }).trigger('resize.chosen');
            $(document).on('settings.ace.chosen', function (e, event_name, event_val) {
                if (event_name != 'sidebar_collapsed') return;
                $('.chosen-select').each(function () {
                    var $this = $(this);
                    $this.next().css({'width': $this.parent().width()});
                });
            });
            $('#chosen-multiple-style .btn').on('click', function (e) {
                var target = $(this).find('input[type=radio]');
                var which = parseInt(target.val());
                if (which == 2) $('#form-field-select-4').addClass('tag-input-style');
                else $('#form-field-select-4').removeClass('tag-input-style');
            });
        }
    });
</script>
</html>